//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package objects;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Set;

public class Field {
    public static final int Empty = 400000;
    private final int ID;
    private boolean isEnabled = false;
    private int count = 0;
    private static final LinkedHashMap<Integer, FieldsEntry> nameById = new LinkedHashMap();
    private static final LinkedHashMap<String, FieldsEntry> idByName = new LinkedHashMap();

    public Field(int ID) {
        this.ID = ID;
    }

    public void configure(boolean enabled, int hcount) {
        this.isEnabled = enabled;
        this.count = hcount;
    }

    public boolean getEnabled() {
        return this.isEnabled;
    }

    public void setCount(int count) {
        if(count < 0) {
            count = 0;
        }

        this.count = count;
    }

    public int getCount() {
        return this.count;
    }

    public int id() {
        return this.ID;
    }

    public int timeSec() {
        Integer val = Integer.valueOf(0);
        FieldsEntry fe = (FieldsEntry)nameById.get(Integer.valueOf(this.ID));
        if(fe != null) {
            val = Integer.valueOf(fe.getTimeMin().intValue() * 60 + fe.getTimeSec().intValue());
        }

        return val.intValue();
    }

    public static FieldsEntry getEntryById(int id) {
        return (FieldsEntry)nameById.get(Integer.valueOf(id));
    }

    public static FieldsEntry getEntryByName(String name) {
        return (FieldsEntry)idByName.get(name);
    }

    public static Integer unlockLevelFromId(int id) {
        FieldsEntry ff = (FieldsEntry)nameById.get(Integer.valueOf(id));
        return ff != null?ff.getUnlockLevel():null;
    }

    public static int unlockedFieldsCount(int currentLevel) {
        int rval = 0;
        Iterator var3 = nameById.values().iterator();

        while(var3.hasNext()) {
            FieldsEntry fe = (FieldsEntry)var3.next();
            if(currentLevel >= fe.getUnlockLevel().intValue()) {
                ++rval;
            }
        }

        return rval;
    }

    public static String getNameById(int fieldId) {
        FieldsEntry ff = (FieldsEntry)nameById.get(Integer.valueOf(fieldId));
        return ff != null?ff.getName():null;
    }

    public static Integer getIdByName(String name) {
        FieldsEntry ff = (FieldsEntry)idByName.get(name);
        return ff != null?ff.getGlobalId():null;
    }

    public static Set<Integer> getIds() {
        return nameById.keySet();
    }

    public static void clear() {
        nameById.clear();
        idByName.clear();
    }

    public static int getNextInstanceId() {
        return nameById.size();
    }

    public static void addFieldEntry(FieldsEntry fe) {
        nameById.put(fe.getGlobalId(), fe);
        idByName.put(fe.getName(), fe);
    }

    public String toString() {
        return nameById.get(Integer.valueOf(this.ID)) + ": count: " + this.count;
    }
}
